/* @(#)GSSystemConfigurator.java
 *
 * Project: BUS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   Janus Liu    2005-12-22 建立
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.lib;

import java.util.Date;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * @author simonyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GSAutoAuditongDateConfigurator {
    

    private static final String RESOURCE_NAME = "date";

    private static boolean iIsInitialed = false;

    private static ResourceBundle iResourceBundle = null;
     private static GSAutoAuditongDateConfigurator iGSSystemConfigurator = null;

    private GSAutoAuditongDateConfigurator() throws Exception {
        bundle();
    }
    public static GSAutoAuditongDateConfigurator getInstance() throws Exception{
    	if(iGSSystemConfigurator == null){
    		iGSSystemConfigurator = new GSAutoAuditongDateConfigurator();
    	}
    	return iGSSystemConfigurator;
    }
   
    private void bundle() throws Exception {
	    if (!iIsInitialed) {
	        try {
	            iResourceBundle = ResourceBundle.getBundle(RESOURCE_NAME);
	            iIsInitialed = true;
	        }
	        catch (Exception e) {
	            e.printStackTrace();
	            throw new Exception("无法读取系统配置文件配置信息");
	        }
	    }	    
    }
    
 
    
    public static String getParam(String aParamName) throws MissingResourceException {
        if (!iIsInitialed) {
            throw new MissingResourceException("系统参数解析类未初始化", "GSAutoAuditongDateConfigurator", "");
        }

        String tValue = null;
        if (aParamName.indexOf("p.") == 0) {
            try {
                tValue = iResourceBundle.getString(aParamName);
            }
            catch (Exception e) { }
        }
        
        return tValue;
    }
    public static String getParamByKey(String aParamName) throws MissingResourceException {
        if (!iIsInitialed) {
            throw new MissingResourceException("系统参数解析类未初始化", "GSAutoAuditongDateConfigurator", "");
        }

        String tValue = null;
            try {
                tValue = iResourceBundle.getString(aParamName);
            }
            catch (Exception e) { }
        
        return tValue;
    }
    public static String [] getParams(String aParamName) throws MissingResourceException {
        if (!iIsInitialed) {
            throw new MissingResourceException("系统参数解析类未初始化", "GSAutoAuditongDateConfigurator", "");
        }

        String  value = null;
        if (aParamName.indexOf("p.") == 0) {
            try {
               value = iResourceBundle.getString(aParamName);
               return value.split(",");
                
            }
            catch (Exception e) { }
        }
        
        return null;
    }
    
    public static boolean isAutoAuditing(){
        boolean flag = false;
        Date date = new Date();
        int month = date.getMonth()+1;
        String dates [] = getParams("p."+month);
        for(int i =0;i<dates.length;i++ ){
            if(dates[i].equals(""+date.getDate())){
                flag = true;
                break;
            }
        }
        return flag;
    }
    public static boolean isShareDatesWarehouses(String warehouseCode){
        boolean flag = false;
        Date date = new Date();
        int month = date.getMonth()+1;
        String dates [] = getParamByKey("w").split(",");
        for(int i =0;i<dates.length;i++ ){
            if(dates[i].equals(warehouseCode)){
                flag = true;
                break;
            }
        }
        return flag;
    }
    
    public static boolean isNoShareWarehouseProductDatesWarehouses(String warehouseCode){
        boolean flag = false;
        Date date = new Date();
        int month = date.getMonth()+1;
        String dates [] = getParamByKey("warehouse_product_property_no_share").split(",");
        for(int i =0;i<dates.length;i++ ){
            if(dates[i].equals(warehouseCode)){
                flag = true;
                break;
            }
        }
        return flag;
    }
    
    public static String getReportYKProductMonthStart(){
        String dates = getParamByKey("report_YK_Product_Month_START");
        return dates;
    }
    
    public static String getReportYKProductMonthEnd(){
        String dates = getParamByKey("report_YK_Product_Month_END");
        return dates;
    }
    
    public static String getProjectCode(){
        String dates = getParamByKey("project_code");
        return dates;
    }
    
    public static String[] getAirWarehouseCode(){
        String dates [] = getParamByKey("air_warehouse_code").split(",");
        return dates;
    }
    
    public static String getBackProjectManagerUrl(){
    	String dates = getParamByKey("back_project_manager_url");
    	return dates;
    }
    
    public static String getBackProjectManagerErrorUrl(){
    	String dates = getParamByKey("back_project_manager_error_url");
    	return dates;
    }
    
    public static String getUploadTime(){
    	String dates = getParamByKey("upload_time");
    	return dates;
    }
    
    public static String getFiltrateFieldAll(){
    	String dates = getParamByKey("filtrate_field_all");
    	return dates;
    }
    
    public static String getFiltrateFieldTable(){
    	String dates = getParamByKey("filtrate_field_table");
    	return dates;
    }

}